﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Koonsoft.CustomerService.BLL;
using Koonsoft.CustomerService.Entity;

namespace CustomerService.FixProblem
{
    public partial class ProblemList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind();
            }
        }

        protected void AspNetPager1_PageChanged(object src, EventArgs e)
        {
            Bind(AspNetPager1.CurrentPageIndex);
        }

        private void Bind(int pageIndex = 1)
        {
            string msg;
            List<Issue> issues = new IssuesBLL().GetIssues(new Issue() { Status = new WFBLL().GetWfByState(Label1.Text) }, out msg);
            AspNetPager1.RecordCount = issues.Count;
            PagedDataSource pds = new PagedDataSource();
            pds.DataSource = issues;
            pds.AllowPaging = true;
            pds.CurrentPageIndex = pageIndex - 1;
            try
            {
                pds.PageSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PageSize"]);
                AspNetPager1.PageSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PageSize"]);
            }
            catch
            {
                pds.PageSize = 15;
                AspNetPager1.PageSize = 15;
            }
            GridView1.DataSource = pds;
            GridView1.DataBind();

        }
    }
}